/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sys.dao;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import sys.bean.MotivoBloqueioBean;
import sys.utils.ConexaoADS;

/**
 *
 * @author Administrador
 */
public class MotivoBloqueioDao {
    
    public static MotivoBloqueioBean consultaMotivoBloqueio(String codCliente) throws SQLException, IOException {
        
        Connection con = ConexaoADS.getConection();
        
        String sql = "SELECT C24CODIGO, C24DESC FROM SPAC24\n"
                + "INNER JOIN SPAC05 ON (C05MOTBLOQ = C24CODIGO)\n"
                + "WHERE C05CODIGO = '" + codCliente + "'";
        
        PreparedStatement stmt = con.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();
        
        MotivoBloqueioBean mb = new MotivoBloqueioBean();
        
        while (rs.next()) {
            
            mb.setCodigo(rs.getString("C24CODIGO"));
            mb.setDescricao(rs.getString("C24DESC"));
            
        }
        
        stmt.close();
        con.close();
        
        return mb;
        
    }
}
